<?php

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
| STORE Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/

$base_dir = 'App\backend\controllers';

Route::middleware('auth:sanctum')->get('/user', function (Request $request) {
    return $request->user();
});



//商品模块
Route::group(['prefix' => '', 'namespace' => $base_dir . '\goods', 'middleware' => ['token.auth']], function () {
    //商品管理
    Route::group(['prefix' => 'goods'],function (){
        //商品列表
        Route::get('/list', 'GoodsController@getGoodsList');
        //添加/编辑商品 基础信息
        Route::post('/base_modify', ["uses" => 'GoodsController@modifyBaseGoods']);
        //添加/编辑商品 价格/库存
        Route::post('/price_stock_modify', ["uses" => 'GoodsController@modifyPriceStockGoods']);
        //添加/编辑商品 附加规格
        Route::post('/sku_info_modify', ["uses" => 'GoodsController@modifySkuInfoGoods']);
        //添加/编辑商品 物流设置
        Route::post('/logistics_modify', ["uses" => 'GoodsController@modifyLogisticsGoods']);
        //添加/编辑商品 商品详情
        Route::post('/description_modify', ["uses" => 'GoodsController@modifyDescriptionGoods']);
        //添加/编辑商品 商品参数
        Route::post('/params_modify', ["uses" => 'GoodsController@modifyParamsGoods']);
        //添加/编辑商品 商品限购
        Route::post('/quota_modify', ["uses" => 'GoodsController@modifyQuotaGoods']);
        //添加/编辑商品 商品状态
        Route::post('/state_modify', ["uses" => 'GoodsController@modifyStateGoods']);
        //删除/下架商品
        Route::post('/removal_del', ["uses" => 'GoodsController@removalDelGoods']);
        //商品详情
        Route::get('/info', 'GoodsController@getGoodsInfo');
    });
    //商品分类
    Route::group(['prefix' => 'cate'],function (){
        //商品分类列表
        Route::get('/list', 'CategoryController@getList');
        //添加/编辑商品分类
        Route::post('/modify', 'CategoryController@categoryModify');
        //显示/隐藏商品分类
        Route::post('/enabled', 'CategoryController@categoryEnabled');
        //删除商品分类
        Route::post('/delete', 'CategoryController@categoryDelete');
    });
    //商品标签
    Route::group(['prefix' => 'tag'],function (){
        //商品分组列表
        Route::get('/list', 'GoodsTagController@getList');
        //添加/编辑商品分组
        Route::post('/modify', 'GoodsTagController@goodsTagModify');
        //删除商品分组
        Route::post('/delete', 'GoodsTagController@goodsTagDelete');
    });
    //商品关键词
    Route::group(['prefix' => 'keyword'],function (){
        //商品分组列表
        Route::get('/list', 'GoodsKeywordController@getList');
        //添加/编辑商品分组
        Route::post('/modify', 'GoodsKeywordController@goodsKeywordModify');
        //删除商品分组
        Route::post('/delete', 'GoodsKeywordController@goodsKeywordDelete');
    });
    //商品分组
    Route::group(['prefix' => 'group'],function (){
        //商品分组列表
        Route::get('/list', 'GoodsGroupController@getList');
        //商品分组详情
        Route::get('/info', 'GoodsGroupController@goodsGroupInfo');
        //添加/编辑商品分组
        Route::post('/modify', 'GoodsGroupController@goodsGroupModify');
        //删除商品分组
        Route::post('/delete', 'GoodsGroupController@goodsGroupDelete');
    });
    //商品规格
    Route::group(['prefix' => 'sku'],function (){
        //商品规格列表
        Route::get('/list', 'GoodSkuController@getList');
        //商品分组详情
        Route::get('/info', 'GoodSkuController@goodsSkuInfo');
        //添加/编辑商品规格
        Route::post('/modify', 'GoodSkuController@goodSkuModify');
        //删除商品规格
        Route::post('/delete', 'GoodSkuController@goodSkuDelete');
    });
    //商品支持
    Route::group(['prefix' => 'support'],function (){
        //商品支持列表
        Route::get('/list', 'GoodSupportController@getList');
        //商品支持详情
        Route::get('/info', 'GoodSupportController@goodSupportInfo');
        //添加/编辑商品支持
        Route::post('/modify', 'GoodSupportController@goodSupportModify');
        //删除商品支持
        Route::post('/delete', 'GoodSupportController@goodSupportDelete');
    });
    //商品参数
    Route::group(['prefix' => 'params'],function (){
        //商品参数列表
        Route::get('/list', 'GoodParamsController@getList');
        //商品参数详情
        Route::get('/info', 'GoodParamsController@goodParamsInfo');
        //添加/编辑商品参数
        Route::post('/modify', 'GoodParamsController@goodParamsModify');
        //删除商品参数
        Route::post('/delete', 'GoodParamsController@goodParamsDelete');
        //修改商品参数状态 状态：1:显示  0:隐藏
        Route::post('/state', 'GoodParamsController@goodParamsState');
    });
    //回收站
    Route::group(['prefix' => 'depot'],function (){
        //回收站列表
        Route::get('/list', 'GoodsDepotController@getList');
        //恢复回收站
        Route::post('/restore', 'GoodsDepotController@goodsRestore');
        //删除回收站
        Route::post('/delete', 'GoodsDepotController@goodsDelete');
    });
    //商品参数设置
    Route::group(['prefix' => 'setting'],function (){
        //商品设置信息
        Route::get('/info', 'GoodSettingController@getInfo');
        //编辑商品设置
        Route::post('/edit', 'GoodSettingController@goodSetting');
    });

});

//订单模块
Route::group(['prefix' => '', 'namespace' => $base_dir . '\orders', 'middleware' => ['token.auth']], function () {
    //订单管理
    Route::group(['prefix' => 'orders'],function (){
        //订单列表
        Route::get('/list', 'OrdersController@getOrdersList');
    });
});

//抽奖
Route::group(['prefix' => '', 'namespace' => $base_dir . '\lottery_draw', 'middleware' => ['token.auth']], function () {
    //测试抽奖和开奖
    Route::any('/go_open', 'LifeFreeController@goOpenDraw');
    Route::any('/go_drow_res', 'BigWheelController@goLotteryResults');
    Route::any('/go_drow', 'BigWheelController@goLottery');
    //抽奖--大转盘
    Route::group(['prefix' => 'bigwheel'],function (){
        //测试用--增加抽奖记录
        Route::any('/add_log', 'BigWheelController@addLotteryRecord');
        //活动列表
        Route::any('/list', 'BigWheelController@getList');
        //抽奖记录
        Route::any('/log_list', 'BigWheelController@lotteryRecordList');
        //活动-基础设置
        Route::any('/set_base', 'BigWheelController@baseSettings');
        //活动-奖品设置
        Route::any('/set_prize', 'BigWheelController@prizeSettings');
        //活动-抽奖次数设置
        Route::any('/draws_rule', 'BigWheelController@numberOfDraws');
        //活动-页面装修
        Route::any('/page', 'BigWheelController@pageDecoration');
        //获取活动信息
        Route::any('/get_info', 'BigWheelController@getActivity');
        //更新活动基础信息
        Route::any('/modify_base', 'BigWheelController@modifyActivityBase');
        //删除活动信息
        Route::any('/del', 'BigWheelController@delActivity');

        //设置奖品--获取商品列表
        Route::any('/get_goods_list', 'BigWheelController@getPrizeGoodsList');
        //设置奖品--获取微券列表
        Route::any('/get_coupon_list', 'BigWheelController@getPrizeCouponList');
        //奖品设置--商品
        Route::any('/set_prize_goods', 'BigWheelController@setGoodsToPrize');
        //奖品设置--微券
        Route::any('/set_prize_coupon', 'BigWheelController@setCouponToPrize');
        //奖品设置--积分
        Route::any('/set_prize_point', 'BigWheelController@setPointToPrize');
        //奖品设置--余额
        Route::any('/set_prize_balance', 'BigWheelController@setBalanceToPrize');
        //获取奖品列表
        Route::any('/get_prize_list', 'BigWheelController@getActivityPrizeList');
        //编辑--获取奖品信息
        Route::any('/get_prize', 'BigWheelController@getActivityPrize');
        //编辑--更新奖品信息
        Route::any('/modify_prize', 'BigWheelController@modifyActivityPrize');
        //删除奖品数据
        Route::any('/del_prize', 'BigWheelController@delActivityPrize');
    });

    //抽奖--生活自由
    Route::group(['prefix' => 'life'],function (){
        //活动列表
        Route::any('/list', 'LifeFreeController@getList');
        //抽奖记录
        Route::any('/log_list', 'LifeFreeController@lotteryRecordList');
        //抽奖记录--奖券列表
        Route::any('/ticket_list', 'LifeFreeController@getTicketList');
        //活动-基础设置
        Route::any('/modify_base', 'LifeFreeController@modifyActivity');
        //活动--奖品设置
        Route::any('/set_prize', 'LifeFreeController@prizeSetting');
        //活动--开奖设置
        Route::any('/set_draw_prize', 'LifeFreeController@drawPrizeSetting');
        //编辑--获取活动详情
        Route::any('/get_info', 'LifeFreeController@getActivity');
        //删除活动
        Route::any('/del', 'LifeFreeController@delActivity');

    });
});

//卡券模块
Route::group(['prefix' => '', 'namespace' => $base_dir . '\coupon', 'middleware' => ['token.auth']], function () {
    //卡券
    Route::group(['prefix' => 'coupon'],function (){
        //通用卡券top数据
        Route::any('/universalTop', 'CouponController@universalCouponTop');
        //专用卡券top数据
        Route::any('/dedicatedTop', 'CouponController@dedicatedCouponTop');
        //通用卡券列表
        Route::any('/universalList', 'CouponController@universalCouponLists');
        //专用卡券列表
        Route::any('/dedicatedList', 'CouponController@dedicatedCouponLists');
        //通用卡券详情
        Route::any('/universalDetail', 'CouponController@universalCouponDetail');
        //专用卡券详情
        Route::any('/dedicatedDetail', 'CouponController@dedicatedCouponDetail');
        //添加/编辑通用券
        Route::post('/universalModify', 'CouponController@modifyUniversalCoupon');
        //添加/编辑专用券
        Route::post('/dedicatedModify', 'CouponController@modifyDedicatedCoupon');
        //删除卡券
        Route::any('/delCoupon', 'CouponController@delCoupon');
        //发券
        Route::any('/sendCoupon', 'CouponController@sendCoupon');
        //使用记录
        Route::any('/useLog', 'CouponController@useLog');
        //商户券列表
        Route::any('/storeCoupon', 'CouponController@storeCouponLists');
        //商户券详情
        Route::any('/storeDetail', 'CouponController@storeDetail');
        //商户券停售
        Route::any('/haltSales', 'CouponController@haltSales');
    });
});

//登录
Route::group(['prefix' => '', 'namespace' => $base_dir , 'middleware' => []], function () {
    //登录
    Route::post('/logon', 'LogonController@adminLogon');
});

//公共模块
Route::group(['prefix' => '', 'namespace' => $base_dir .'\common' , 'middleware' => []], function () {
    Route::group(['prefix' => 'common'],function (){
        //获取省市区三级联动
        Route::get('/area', 'AreaController@getList');
    });
});

//会员个人信息
Route::group(['prefix' => '', 'namespace' => $base_dir . '\member', 'middleware' => ['token.auth']], function () {
    Route::group(['prefix' => 'member'],function (){
        //列表
        Route::get('/list', 'MemberController@list');
        //列表个人详情
        Route::get('/details', 'MemberController@getDetails');
        //个人信息
        Route::get('/info', 'MemberController@getInfo');
        //添加会员
        Route::post('/addMember', 'MemberController@addMember');
        //编辑会员
        Route::put('/editMember', 'MemberController@editMember');
        //删除会员
        Route::delete('/deleteMember', 'MemberController@deleteMember');
        //VIP等级
        Route::group(['prefix' => 'level'],function (){
            //列表
            Route::get('/list', 'MemberLevelController@list');
            //添加/编辑
            Route::post('/modify', 'MemberLevelController@modify');
            //删除
            Route::post('/delete', 'MemberLevelController@delete');
        });
        //用户标签
        Route::group(['prefix' => 'group'],function (){
            //列表
            Route::get('/list', 'MemberGroupController@list');
            //详情
            Route::get('/details', 'MemberGroupController@details');
            //添加
            Route::post('/addGroup', 'MemberGroupController@addGroup');
            //编辑
            Route::put('/editGroup', 'MemberGroupController@editGroup');
            //删除
            Route::delete('/deleteGroup', 'MemberGroupController@deleteGroup');
        });
    });
});

//全局权限
Route::group(['prefix' => '', 'namespace' => $base_dir, 'middleware' => ['token.auth']], function () {
    //角色管理
    Route::group(['prefix' => 'role'], function () {
        //角色列表
        Route::get('/list', 'role\RoleController@lists');
        //角色详情
        Route::post('/detail', 'role\RoleController@detail');
        //添加/编辑 角色
        Route::post('/modify', 'role\RoleController@modify');
        //删除 角色
        Route::post('/delete', 'role\RoleController@delete');
    });
    //菜单管理
    Route::group(['prefix' => 'menu'], function () {
        //菜单列表
        Route::get('/menu_role_list', 'menu\MenuController@getMenuRoleList');
        //菜单列表
        Route::get('/list', 'menu\MenuController@lists');
        //菜单详情
        Route::post('/detail', 'menu\MenuController@detail');
        //添加/编辑 菜单
        Route::post('/modify', 'menu\MenuController@modify');
        //删除 菜单
        Route::post('/delete', 'menu\MenuController@delete');
    });
    //操作员管理
    Route::group(['prefix' => 'admin_users'], function () {
        //操作员列表
        Route::get('/list', 'admin\adminUsersController@lists');
        //添加编辑操作员
        Route::any('/modify', 'admin\adminUsersController@modify');
        //操作员详情
        Route::any('/detail', 'admin\adminUsersController@detail');
        //改变审核状态
        Route::any('/updateStatus', 'admin\adminUsersController@updateStatus');
        //删除操作员
        Route::any('/delete', 'admin\adminUsersController@delete');
    });
    //日志
    Route::group(['prefix' => 'log'], function () {
        //登入日志
        Route::get('/login_list', 'log\AdminLoginLogController@list');
        //操作日志
        Route::get('/list', 'log\AdminOperationAllLogController@list');
    });
});


//分销商等级
Route::group(['prefix' => '', 'namespace' => $base_dir . '\commission', 'middleware' => []], function () {
    //分销商等级列表
    Route::get('/agentLevelLists', 'AgentLevelController@agentLevelLists');
    //分销商等级详情
    Route::get('/agentLevelDetail/{id}', 'AgentLevelController@agentLevelDetail');
    //分销商等级添加
    Route::post('/addAgentLevel', 'AgentLevelController@addAgentLevel');
    //分销商等级修改
    Route::put('/editAgentLevel', 'AgentLevelController@editAgentLevel');
    //分销商等级删除
    Route::delete('/deleteAgentLevel', 'AgentLevelController@deleteAgentLevel');
    //分销商等级下拉
    Route::get('/getAgentLevel', 'AgentLevelController@getAgentLevel');
    //升级策略下拉
    Route::get('/getUpgradeStrategy', 'AgentLevelController@getUpgradeStrategy');
    //降级策略下拉
    Route::get('/getFallStrategy', 'AgentLevelController@getFallStrategy');
    //分销商等级启用
    Route::put('/setLevelStatus', 'AgentLevelController@setLevelStatus');
});


//全局配置
Route::group(['prefix' => '', 'namespace' => $base_dir . '\setting', 'middleware' => ['token.auth']], function () {
    Route::group(['prefix' => 'setting'],function (){
        //商城设置
        Route::any('/shop', 'SettingController@setShop');
        //订单设置
        Route::any('/order', 'SettingController@setOrder');
        //物流查询
        Route::any('/express', 'SettingController@setExpress');
        //短信
        Route::any('/sms', 'SettingController@setSms');
        //联系方式
        Route::any('/contact', 'SettingController@setContact');
        //优惠券
        Route::any('/coupon', 'SettingController@setCoupon');
        //分享
        Route::any('/share', 'SettingController@setShare');
        //地图设置
        Route::any('/map', 'SettingController@setMap');
        //邮箱配置
        Route::any('/email', 'SettingController@setEmail');
        //支付方式
        Route::any('/pay', 'SettingController@setPay');
        //幻灯片
        Route::group(['prefix' => 'slide'],function (){
            //列表
            Route::any('/list', 'SlideController@getList');
            //添加/编辑
            Route::any('/modify', 'SlideController@setModify');
            //删除
            Route::any('/delete', 'SlideController@optDelete');
        });
        //公告
        Route::group(['prefix' => 'notice'],function (){
            //列表
            Route::any('/list', 'NoticeController@getList');
            //添加/编辑
            Route::any('/modify', 'NoticeController@setModify');
            //删除
            Route::any('/delete', 'NoticeController@optDelete');
        });
        //广告位
        Route::group(['prefix' => 'advs'],function (){
            //列表
            Route::any('/list', 'AdvsController@getList');
            //添加/编辑
            Route::any('/modify', 'AdvsController@setModify');
            //删除
            Route::any('/delete', 'AdvsController@optDelete');
        });
        //客服设置
        Route::group(['prefix' => 'customerService'],function (){
            //列表
            Route::any('/list', 'CustomerServiceController@getList');
            //添加/编辑
            Route::any('/modify', 'CustomerServiceController@setModify');
            //删除
            Route::any('/delete', 'CustomerServiceController@optDelete');
        });
        //搜索设置
        Route::group(['prefix' => 'search'],function (){
            //列表
            Route::any('/list', 'SearchController@getList');
            //添加/编辑
            Route::any('/modify', 'SearchController@setModify');
            //删除
            Route::any('/delete', 'SearchController@optDelete');
        });
    });
});
